﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ESOL.Common.Entity;
using ESOL.Business.Prod;

namespace ESOL.WinUI.Manufacture
{
    public partial class frmPrintFormPickingPlanOrder : BaseForm.frmBaseDialogyForm
    {
        #region vars
        private DataTable AllPickingPrint;
        private ProdPickingMaterialEntity mSelectedPickingMaterial;
        #endregion

        #region ctors
        public frmPrintFormPickingPlanOrder(ProdPickingMaterialEntity entity, DataTable dt)
        {
            InitializeComponent();

            AllPickingPrint = dt;
            mSelectedPickingMaterial = entity;
            UICommon.UICommonFunctions.BindComboboxByCommonItem(cmbPickingPrintType, "PICKT", true);
            frmPrintTemplatePickingPlanOrder frm = new frmPrintTemplatePickingPlanOrder(entity, dt);
            printControl1.PrintingSystem = frm.PrintingSystem;
            frm.CreateDocument();
        }
        #endregion

        private void cmbPickingPrintType_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable dtNew = AllPickingPrint.Clone();
            switch (cmbPickingPrintType.SelectedValue.ToString())
            {
                case "PICKT01"://锻打                    
                    foreach (DataRow dr in AllPickingPrint.Rows)
                    {
                        if (dr["PICKING_TYPE"].ToString().Equals("PICKT01"))
                            dtNew.ImportRow(dr);
                    }
                    break;
                case "PICKT02"://管料
                    foreach (DataRow dr in AllPickingPrint.Rows)
                    {
                        if (dr["PICKING_TYPE"].ToString().Equals("PICKT02"))
                            dtNew.ImportRow(dr);
                    }
                    break;
                case "PICKT03"://直车
                    foreach (DataRow dr in AllPickingPrint.Rows)
                    {
                        if (dr["PICKING_TYPE"].ToString().Equals("PICKT03"))
                            dtNew.ImportRow(dr);
                    }
                    break;
                default:
                    dtNew=AllPickingPrint.Copy();
                    break;
            }
            frmPrintTemplatePickingPlanOrder frm = new frmPrintTemplatePickingPlanOrder(mSelectedPickingMaterial, dtNew);
            printControl1.PrintingSystem = frm.PrintingSystem;
            frm.CreateDocument();
        }
    }
}
